// The Vue build version to load with the `import` command
// (runtime-only or standalone) has been set in webpack.base.conf with an alias.
import Vue from 'vue'
import router from './router'
import store from './store/index'
import Vuelidate from 'vuelidate';

Vue.use(Vuelidate);
import $ from 'jquery'
window.$      =$;
window.bus    =new Vue();
window.store  =store;
Vue.config.productionTip = false;
router.beforeEach((to,from,next)=>{
  if(to.meta.requireAuth) {   // 需要验证是否登录并且token是否过期
    store.commit('checkTimeout');
    let user    =store.state.userInfo;let flag=false;
    let tokenAuth=store.state.tokenAuth;
    for(let index in user){flag=true;break;}
    if(!flag || !tokenAuth){ next({
      path:'/',
      query:{jump:to.path}
    })}
  }next();
});
/* eslint-disable no-new */
new Vue({
  router,
  store,
}).$mount('#page-wrapper');
